Route:game("SYNCSPEED",function(player,bytes)
    local syncValue = NetServer:createSyncValue(player,"speed",0);
    player.user["SyncSpeed"] = Timer:schedule(function()
        syncValue.value = player.velocity.x * player.velocity.x + player.velocity.y * player.velocity.y;
    end,0,4);
end);

Route:game("UNSYNCSPEED",function(player,bytes)
    if player.user["SyncSpeed"] ~= nil then
        player.user["SyncSpeed"]:cancel();
        player.user["SyncSpeed"] = nil;
    end
end);

if UI ~= nil then

    Class("SyncSpeed",function(SyncSpeed)
        SyncSpeed.STATIC = true;
        
        SyncSpeed.isShow = false;
        SyncSpeed.text = UI.Text:Create();
        SyncSpeed.text:Set({
            text = "0",
            font = "large",
            align = "center",
            x = 0,
            y = 0,
            width = 320,
            height = 120,
            r=0,g=0,b=0,a=255,
        });
        SyncSpeed.text:Hide();
        SyncSpeed.syncValue = NULL;
    end)

    
    MainMenu.root:add({
        "显示地速",
        function(item)
            if SyncSpeed.isShow == false then
                NetClient:request(Request(Route.Game.SYNCSPEED),function(bytes)
                    if SyncSpeed.syncValue == NULL then
                        NetClient:createSyncValue("speed",function(self)
                            SyncSpeed.text:Set({text = ""..math.sqrt(self.value)});
                        end);
                    end
                    SyncSpeed.text:Show();
                end);
                item.name = "隐藏低速";
            else
                NetClient:request(Request(Route.Game.UNSYNCSPEED),function(bytes)
                    SyncSpeed.text:Hide();
                end);
                item.name = "显示地速";
            end
            SyncSpeed.isShow = not SyncSpeed.isShow;
        end
    });

end